﻿// anip.cpp : Defines the entry point for the application.
//

#include "anip.h"
#include "bind.h"
#include "color/truecolor.h"
#include "editor/windowman.h"

using namespace std;
using namespace anip;

int main(int argc, char **argv)
{
	try
	{
		cout << "Initializing graphics context..." << endl;
		anip::init();
		TrueColor::init();
		Context::init({ 1080, 720 });

		cout << "Initializing editor..." << endl;
		editor::Settings::initDefault();
		editor::Globals::init();
		auto mainWindow = new editor::WindowManager;

		cout << "\nDone.\n" << endl;
		mainWindow->mainLoop();

		cout << "Cleaning up..." << endl;
		delete mainWindow;

		cout << "Finalizing fonts..." << endl;
		FontManager::finalize();

		cout << "Finalizing globals..." << endl;
		editor::Globals::finalize();
		TrueColor::finalize();
		anip::finalize();

		cout << "Exiting..." << endl;

		return 0;
	}
	catch (exception& e)
	{
		cerr << "*** Fatal error ***" << endl;
		cerr << e.what();
		return 1;
	}
}
